<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Creative - Bootstrap 3 Responsive Admin Template">
    <meta name="author" content="GeeksLabs">
    <meta name="keyword" content="Creative, Dashboard, Admin, Template, Theme, Bootstrap, Responsive, Retina, Minimal">

</head>

<body>
<div class="col-lg-12">
    <ol class="breadcrumb">
        <li><i class="fa fa-home"></i>
            <a href="index.html">Home</a>
        </li>
        <li><i class=""></i>添加获奖信息</li>
    </ol>

    <!--主体内容 stat-->
    <div class="mcomment" id="addAwardInfo">

        <h3 class="page-header"><i class=""></i>添加获奖信息</h3>
        <table class=" ">

            <tr>

                <td><label for="awardPersonName">获奖人姓名：</label></td>
                <td><input v-model="name" type="text" class="form-control" id="awardPersonName" placeholder="请输入获奖人姓名"/>
                </td>

            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>
            <tr>

                <td><label for="matchName">获奖比赛名称：</label></td>
                <td><input v-model="coName" type="text" class="form-control" id="matchName" placeholder="请输入获奖比赛名称"/>
                </td>

            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>
            <tr>

                <td><label for="awardCompany">颁奖单位：</label></td>
                <td><input v-model="company " type="text" class="form-control" id="awardCompany"
                           placeholder="请输入颁奖单位名称"/></td>

            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td><label for="awardLevel">获奖等级：</label></td>
                <td>

                    <select v-model="grade" class="form-control" id="awardLevel">
                        <option v-for=" gr in gradelist " v-bind:value="gr.grade ">
                            {{gr.gradeName}}
                        </option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td><label for="awardType">获奖类型：</label></td>
                <td>
                    <select v-model="awards" class="form-control" id="awardType">
                        <option v-for=" awa in awardslist " v-bind:value="awa.awards ">
                            {{awa.awardsName}}
                        </option>
                    </select>

                </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td><label for="awardTime ">获奖时间：</label></td>
                <td><input v-model="winningTime " type="date" class="form-control " id="awardTime "/></td>
            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>

        </table>

        <div class="form-group ">
            <label for="awardContent ">获奖人介绍：</label>
            <!--<textarea v-model="trend " class="form-control " id="noticeContent " cols="100% " rows="10 "></textarea>-->
            <textarea id="text1" class="form-control" style="display: none">
								</textarea>
            <div id="meuen" class="toolbar">
            </div>
            <div style="padding: 5px 0; color: #ccc"></div>
            <div id="editor" class="text"> <!--可使用 min-height 实现编辑区域自动增加高度-->
                <p>请输入内容</p>
            </div>

        </div>
        <center>
            <div style="width: 50%; ">
                <button @click="add() " class="btn btn-default ">添加</button>
                <button class="btn btn-default ">取消</button>
            </div>
        </center>

    </div>
    <!--主体内容end-->

</div>

<script>
    var url1 = 'http://donting.free.idcfengye.com';
    var addaw = new Vue({
        el: '#addAwardInfo',
        data: {
            name: '', //获奖人姓名
            company: '', //颁奖单位
            coName: '', //比赛名（id）

            grade: '1', //比赛等级
            gradelist: [{
                grade: '1',
                gradeName: '一等奖'
            },
                {
                    grade: '2',
                    gradeName: '二等奖'
                },
                {
                    grade: '3',
                    gradeName: '三等奖'
                },
                {
                    grade: '4',
                    gradeName: '优秀奖'
                },


            ],


            awards: '1', //获奖类型
            awardslist: [{
                awards: '1',
                awardsName: '校级'
            },
                {
                    awards: '2',
                    awardsName: '市级'
                },
                {
                    awards: '3',
                    awardsName: '省/部级'
                },
                {
                    awards: '4',
                    awardsName: '国家级'
                },

            ],

            winningTime: '', //获奖时间
            trend: '', //获奖人介绍
            all: []

        },
        methods: {
            add: function () {

                var x=document.getElementById("text1");
                addaw.trend=x.value;
                axios.defaults.withCredentials = true;

                axios.post(url1 + '/winning/add', {
                        'name': addaw.name,
                        'company': addaw.company,
                        'coName': addaw.coName,
                        'grade': addaw.grade,
                        'awards': addaw.awards,
                        'winningTime': addaw.winningTime,
                        'trend': addaw.trend
                }).then(function (response) {
                    var rs = response.data;
                    if (rs.code == 200) {

                        alert("添加成功! ");
                    } else {
                        alert("添加失败! ");
                    }

                }).catch(function (error) {
                    alert("连接超时！ ");
                });

            }
        },
        mounted() {

            var E = window.wangEditor

            var editor =new E('#meuen', '#editor');
            var $text1 = $('#text1')
            editor.customConfig.withCredentials = true
            editor.customConfig.uploadFileName = 'file';
            editor.customConfig.uploadImgServer = url1+'/addEdImgUp'
            editor.customConfig.onchange = function (html) {
                // 监控变化，同步更新到 textarea
                $text1.val(html)
                console.log("更新...")
            }

            editor.create()



        }

    })
</script>

</body>

</html>